'use strict';
angular.module('bjggApp')
  .controller('UserCtrl', function ($scope, $http,$user) {
        
    $scope.name = '';
    $scope.data = [];

    $user.initializeData(function(data){
            $scope.data = data;        
    });

    $scope.search = function(){
          if ($scope.name) {
                $user.searchUser($scope.name,function(data){
                        $scope.data = data;
                });
          }else{
            alert('填东西');
          }
    };

    $scope.create = function(){
          if ($scope.name) {
                var jdata = {id:'3',name:$scope.name};
                $scope.data.push(jdata);
                $user.createUser($scope.name);
          }else{
            alert('填东西');
          }
    };
     
  });